package dapps.entity.monitor;


import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;


public class Empk implements Serializable
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -2510614658358211876L;
	private Element element;
    private Servicemain servicemain;

	public Empk() {        
    }
	public Empk(Element element,Servicemain sm) {   
		this.element = element;
		this.servicemain = sm;
    }
	

	@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
	@JoinColumn(name = "e_id")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public Element getElement() {
		return element;
	}

	public void setElement(Element element) {
		this.element = element;
	}
	
	@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
	@JoinColumn(name = "s_id")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public Servicemain getServicemain() {
		return servicemain;
	}


	public void setServicemain(Servicemain servicemain) {
		this.servicemain = servicemain;
	}
	@Override
	public String toString() {
		return "Empk [element=" + element.getId() + ", servicemain=" + servicemain.getId()
				+ "]";
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((element == null) ? 0 : element.hashCode());
		result = prime * result
				+ ((servicemain == null) ? 0 : servicemain.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Empk other = (Empk) obj;
		if (element == null) {
			if (other.element != null)
				return false;
		} else if (!element.equals(other.element))
			return false;
		if (servicemain == null) {
			if (other.servicemain != null)
				return false;
		} else if (!servicemain.equals(other.servicemain))
			return false;
		return true;
	}


}
